package net.lanelife.casino.cms.aop;

import org.apache.commons.lang.time.StopWatch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class ControllerInterceptor {
	
	private static final Log LOGGER = LogFactory.getLog("控制层拦截器");
	
	@Around("execution(* net.lanelife..controller..*.*(..))")
	public Object logUsesTime(ProceedingJoinPoint pjp) throws Throwable {
		StopWatch watch = new StopWatch();
		watch.start();
		Object retVal = pjp.proceed();
		watch.stop();
		String str = pjp.getTarget().toString();
		LOGGER.info("控制层耗时["+str.substring(str.lastIndexOf(".")+1, str.lastIndexOf("@")) + "." + pjp.getSignature().getName() + ": " + watch.getTime() + "ms]");
        return retVal;
	}

}
